﻿@model CAF.WebSite.Mvc.Admin.Models.Articles.ArticleModel
@using CAF.Infrastructure.Core.Domain.Cms.Articles;
@using CAF.Infrastructure.Core.Domain.Cms.Channels;
@{
    Html.AddCssFileParts(true, "~/Content/assets/global/plugins/chosen/chosen.css");
    Html.AppendScriptParts(true, "~/Content/assets/global/plugins/chosen/chosen.jquery.min.js");
    Html.AddCssFileParts(true, "~/Content/assets/global/plugins/uniform/css/uniform.default.css");

}
@Html.ValidationSummary(false)
@Html.HiddenFor(model => model.Id)

@Html.HiddenFor(model => model.ShowExtendedAttribute)
@Html.HiddenFor(model => model.ShowSpecificationAttributes)
@Html.HiddenFor(model => model.ShowInventory)
@Html.HiddenFor(model => model.ShowPrice)
@Html.HiddenFor(model => model.ShowAttributes)
@Html.HiddenFor(model => model.ShowPromotion)
@if (Model.CategoryShowType == CategoryShowType.LeftNavigationt)
{
    @Html.HiddenFor(model => model.CategoryId)
}
@if (ViewBag.RefreshPage == true)
{
    <script type="text/javascript">
        try {window.opener.document.forms['@(ViewBag.formId)'].@(ViewBag.btnId).click();}
        catch (e){}
        window.close();
    </script>
}
<script>
    function articleEditTab_onAjaxSuccess(tab, pane) {
        applyCommonPlugins(pane);
    }

</script>
@Html.CafSite().TabStrip().Name("article-edit").OnAjaxSuccess("articleEditTab_onAjaxSuccess").HtmlAttributes(new { data_article_id = Model.Id }).Style(TabsStyle.Tabs).Position(TabsPosition.Top).Items(x =>
{
    x.Add().Text(T("Admin.ContentManagement.Articles.Info").Text)
      .Icon("fa fa-pencil fa-lg fa-fw")
      .LinkHtmlAttributes(new { data_tab_name = "Info" })
      .Content(Html.Partial("_CreateOrUpdate.Info", Model).ToHtmlString())
      .Selected(true);

    x.Add().Text(T("Admin.ContentManagement.Articles.Exts").Text)
    .Visible(Model.ShowExtendedAttribute)
    .Icon("fa fa-fw fa-list fa-lg fa-fw")
    .LinkHtmlAttributes(new { data_tab_name = "Exts" })
    .Content(Html.Partial("_CreateOrUpdate.Exts", Model).ToHtmlString());

    x.Add().Text(T("Admin.ContentManagement.Articles.SpecificationAttributes").Text)
    .Visible(Model.ShowSpecificationAttributes && Model.CategoryShowType != CategoryShowType.CheckBox)
    .Icon("fa fa-bars fa-lg fa-fw")
    .LinkHtmlAttributes(new { data_tab_name = "SpecificationAttributes" })
    .Content(Html.Partial("_CreateOrUpdate.SpecificationAttributes", Model).ToHtmlString());

    x.Add().Text(T("Admin.Common.SEO").Text)
    .Icon("fa fa-search fa-lg fa-fw")
    .LinkHtmlAttributes(new { data_tab_name = "SEO" })
    .Content(Html.Partial("_CreateOrUpdate.SEO", Model).ToHtmlString());

    x.Add().Text(T("Admin.ContentManagement.Articles.Inventory").Text)
    .Visible(Model.ShowInventory)
    .Icon("fa fa-archive fa-lg fa-fw")
    .LinkHtmlAttributes(new { data_tab_name = "Inventory" })
    .Content(Html.Partial("_CreateOrUpdate.Inventory", Model).ToHtmlString());

    //x.Add().Text(T("Admin.ContentManagement.Articles.Price").Text)
    //.Visible(Model.ArticleTypeId == (int)ArticleType.Product)
    //.Icon("fa fa-euro fa-lg fa-fw")
    //.LinkHtmlAttributes(new { data_tab_name = "Price" })
    //.Action("LoadEditTab", "Article", new { id = Model.Id, tabName = "Price" })
    //.Ajax();


    x.Add().Text(T("Admin.ContentManagement.Articles.Price").Text)
     .Visible(Model.ShowPrice)
     .Icon("fa fa-euro fa-lg fa-fw")
     .LinkHtmlAttributes(new { data_tab_name = "Price" })
     .Content(Html.Partial("_CreateOrUpdate.Price", Model).ToHtmlString());

    x.Add().Text(T("Admin.ContentManagement.Articles.Attributes").Text)
     .Visible(Model.ShowAttributes)
     .Icon("fa fa-fw fa-list fa-lg fa-fw")
     .LinkHtmlAttributes(new { data_tab_name = "Attributes" })
     .Content(Html.Partial("_CreateOrUpdate.Attributes", Model).ToHtmlString());

    x.Add().Text(T("Admin.ContentManagement.Articles.Promotion").Text)
    .Visible(Model.ShowPromotion)
    .Icon("fa fa-bullhorn fa-lg fa-fw")
    .LinkHtmlAttributes(new { data_tab_name = "Promotion" })
    .Action("LoadEditTab", "Article", new { id = Model.Id, tabName = "Promotion" })
    .Ajax();

    x.Add().Text(T("Admin.ContentManagement.Articles.Acl").Text)
    .Icon("fa fa-users fa-lg fa-fw")
    .LinkHtmlAttributes(new { data_tab_name = "Acl" })
    .Content(Html.Partial("_CreateOrUpdate.Acl", Model).ToHtmlString()).Visible(false);


    x.Add().Text(T("Admin.Common.Sites").Text)
        .Icon("fa fa-globe fa-lg fa-fw")
        .LinkHtmlAttributes(new { data_tab_name = "Sites" })
      .Content(Html.Partial("_CreateOrUpdate.Sites", Model).ToHtmlString()).Visible(Model.ShowSiteContentShare);

    //generate an event
    EngineContext.Current.Resolve<IEventPublisher>().Publish(new TabStripCreated(x, "article-edit", this.Html, this.Model));
})
